/**
 * action类型
 * @type {string}
 */
export const ADD_TODO = 'ADD_TODO';
export const TOGGLE_TODO = 'TOGGLE_DO';
export const SET_VISIBILITY_FILTER = 'SET_VISIBILITY_FILTER';

/**
 * 其他类型的常量
 * @type {{SHOW_ALL: string, SHOW_COMPLETED: string, SHOW_ACTIVE: string}}
 */
export const VisibilityFilters = {
    SHOW_ALL:'SHOW_ALL',
    SHOW_COMPLETED:'SHOW_COMPLETED',
    SHOW_ACTIVE:'SHOW_ACTIVE',
}

/**
 * 创建action函数
 * @param text
 * @returns {{type: string, text: *}}
 */
export function addToDo(text) {
    return {type:ADD_TODO,text}
}

export function toggleToDo(index) {
    return {type:TOGGLE_TODO,index}
}

export function setVisibilityFilter(filter) {
    return {
        type:SET_VISIBILITY_FILTER,
        filter
    }
}
